package com.yzt.message.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * author : Irene
 * e-mail : 821970751@qq.com
 * date   : 2020/5/8 17:31
 * desc   :
 */
public class RySendImageManager {

    public static List<RySendImageObservable> listObservers = new ArrayList<>();


    public interface RySendImageObservable {

        void sendImage(String imagePath, boolean origin, boolean fireStatus);

//        void sendGif(String imagePath, boolean origin, boolean fireStatus, EmojiResponse gif);
    }

    private RySendImageManager() {

    }

    static class InstanceHolder {
        final static RySendImageManager INSTANCE = new RySendImageManager();
    }

    public static RySendImageManager getInstance() {
        return RySendImageManager.InstanceHolder.INSTANCE;
    }


    public void registerSendOpenAgoraObservable(RySendImageManager.RySendImageObservable observable) {
        if (null != observable) {
            if (!listObservers.contains(observable)) {
                listObservers.add(observable);
            }
        }
    }

    public void unRegisterSendOpenAgoraObservable(RySendImageManager.RySendImageObservable observable) {
        if (null != observable) {
            listObservers.remove(observable);
        }
    }

    public void sendImage(String imagePath, boolean origin, boolean fireStatus) {
        for (RySendImageManager.RySendImageObservable observable : listObservers) {
            observable.sendImage(imagePath, origin, fireStatus);
        }
    }

//    public void sendGif(String imagePath, boolean origin, boolean fireStatus, EmojiResponse gif) {
//        for (RySendImageManager.RySendImageObservable observable : listObservers) {
//            if (imagePath.endsWith(".png")) {
//                gif.setIsEmoticon("yes");
//            }
//            if (TextUtils.isEmpty(gif.getIsServer())) {
//                gif.setIsServer("2");
//            }
//            observable.sendGif(imagePath, origin, fireStatus, gif);
//        }
//    }
}
